package cn.befory.pmt;


import de.felixroske.jfxsupport.AbstractJavaFxApplicationSupport;
import de.felixroske.jfxsupport.SplashScreen;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.util.ArrayList;
import java.util.Collection;

@SpringBootApplication
public class PmtApplication extends AbstractJavaFxApplicationSupport {

    public static void main(String[] args) {

//        SplashScreen splashScreen = new SplashScreen() {
//            @Override
//            public String getImagePath() {
//                return "/images/javafx.png";
//            }
//        };
        // 禁用图标
        System.setProperty("java.awt.headless", "false");
        launch(PmtApplication.class, args);
    }


    @Override
    public void init() throws Exception {
        // 清空图标列表
//        setIcons(new ArrayList<>());
        super.init();
    }

    @Override
    public void start(Stage stage) throws Exception {
        // 确保不加载默认图标
        SpringApplication springApplication = new SpringApplication(getClass());
        ApplicationContext context = springApplication.run();

        // 设置舞台
        stage.setTitle("Your Application Title");

        // 加载并显示主视图
        // 假设你有一个主视图类，比如 MainView
        // AbstractFxmlView mainView = context.getBean(MainView.class);
        // Scene scene = new Scene(mainView.getView());
        // stage.setScene(scene);

        // 或者使用简单的场景先让应用运行起来
        StackPane root = new StackPane();
        root.getChildren().add(new Label("Application Started Successfully"));
        Scene scene = new Scene(root, 800, 600);
        stage.setScene(scene);

        stage.show();


//        super.start(stage);
    }

    @Override
    public Collection<Image> loadDefaultIcons() {
        return new ArrayList<>();
    }
}
